//
//  JKScheduleCollectionViewCell.m
//  JKSchedule
//
//  Created by 王冲 on 2019/4/1.
//  Copyright © 2019年 JK科技有限公司. All rights reserved.
//

#import "JKScheduleCollectionViewCell.h"

@implementation JKScheduleCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self layout];
    }
    
    return self;
}

-(void)layout{

    /*
     *  图片的添加
     */
    [self.contentView addSubview:self.iconImage];
}

-(UIImageView *)iconImage{
    
    if (!_iconImage) {
        
        CGFloat radiusWidth = ([UIScreen mainScreen].bounds.size.width-30*2)/(long)[self getNumberOfDaysInMonth];
        // NSLog(@"宽度=%lf",radiusWidth);
        _iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(0,(10-radiusWidth)/2.0, radiusWidth, radiusWidth)];
        _iconImage.contentMode = UIViewContentModeScaleAspectFill;
        _iconImage.image = [UIImage imageNamed:@"wk_study_img"];
    }
    return _iconImage;
}

// 获取当月的天数
- (NSInteger)getNumberOfDaysInMonth
{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSRange range = [calendar rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:[NSDate date]];
    NSUInteger numberOfDaysInMonth = range.length;
    
    return numberOfDaysInMonth;
}



@end
